package com.atguigu.gmall.product.mapper;

import com.atguigu.gmall.model.product.BaseAttrInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface BaseAttrInfoMapper  extends BaseMapper<BaseAttrInfo> {

    /*根据skuId,查询平台属性和平台属性值
SELECT
    bai.id,
    bai.attr_name,
    bai.category_id,
    bai.category_level,
    bav.id attr_value_id,
    bav.value_name,
    bav.attr_id
FROM
    base_attr_info bai
INNER JOIN base_attr_value bav ON bai.id = bav.attr_id
INNER JOIN sku_attr_value sav ON sav.value_id = bav.id
WHERE
    sav.sku_id = #{skuId}
     */
    List<BaseAttrInfo> selectBaseAttrInfoListBySkuId(@Param("skuId")Long skuId);

    /*根据分类id,查询平台属性+平台属性值
select
    bai.id,
    bai.attr_name,
    bai.category_id,
    bai.category_level,
    bav.id attr_value_id,
    bav.value_name
from base_attr_info bai inner join base_attr_value bav
on bai.id=bav.attr_id
where bai.category_id=61 and bai.category_level=3;
        在mybatis传递多个的时候,需要添加注释,后台才能够获取到
     */
    List<BaseAttrInfo> selectBaseAttrInfoList(@Param("category1Id") Long category1Id,
                                              @Param("category2Id") Long category2Id,
                                              @Param("category3Id")Long category3Id);
}
